<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>sstevr.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="SSTEVR.1"></a><a href="sstevr.f.html#SSTEVR.1">SSTEVR</a>( JOBZ, RANGE, N, D, E, VL, VU, IL, IU, ABSTOL,
     $                   M, W, Z, LDZ, ISUPPZ, WORK, LWORK, IWORK,
     $                   LIWORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK driver routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      CHARACTER          JOBZ, RANGE
      INTEGER            IL, INFO, IU, LDZ, LIWORK, LWORK, M, N
      REAL               ABSTOL, VL, VU
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      INTEGER            ISUPPZ( * ), IWORK( * )
      REAL               D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="SSTEVR.22"></a><a href="sstevr.f.html#SSTEVR.1">SSTEVR</a> computes selected eigenvalues and, optionally, eigenvectors
</span><span class="comment">*</span><span class="comment">  of a real symmetric tridiagonal matrix T.  Eigenvalues and
</span><span class="comment">*</span><span class="comment">  eigenvectors can be selected by specifying either a range of values
</span><span class="comment">*</span><span class="comment">  or a range of indices for the desired eigenvalues.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Whenever possible, <a name="SSTEVR.27"></a><a href="sstevr.f.html#SSTEVR.1">SSTEVR</a> calls <a name="SSTEMR.27"></a><a href="sstemr.f.html#SSTEMR.1">SSTEMR</a> to compute the
</span><span class="comment">*</span><span class="comment">  eigenspectrum using Relatively Robust Representations.  <a name="SSTEMR.28"></a><a href="sstemr.f.html#SSTEMR.1">SSTEMR</a>
</span><span class="comment">*</span><span class="comment">  computes eigenvalues by the dqds algorithm, while orthogonal
</span><span class="comment">*</span><span class="comment">  eigenvectors are computed from various &quot;good&quot; L D L^T representations
</span><span class="comment">*</span><span class="comment">  (also known as Relatively Robust Representations). Gram-Schmidt
</span><span class="comment">*</span><span class="comment">  orthogonalization is avoided as far as possible. More specifically,
</span><span class="comment">*</span><span class="comment">  the various steps of the algorithm are as follows. For the i-th
</span><span class="comment">*</span><span class="comment">  unreduced block of T,
</span><span class="comment">*</span><span class="comment">     (a) Compute T - sigma_i = L_i D_i L_i^T, such that L_i D_i L_i^T
</span><span class="comment">*</span><span class="comment">          is a relatively robust representation,
</span><span class="comment">*</span><span class="comment">     (b) Compute the eigenvalues, lambda_j, of L_i D_i L_i^T to high
</span><span class="comment">*</span><span class="comment">         relative accuracy by the dqds algorithm,
</span><span class="comment">*</span><span class="comment">     (c) If there is a cluster of close eigenvalues, &quot;choose&quot; sigma_i
</span><span class="comment">*</span><span class="comment">         close to the cluster, and go to step (a),
</span><span class="comment">*</span><span class="comment">     (d) Given the approximate eigenvalue lambda_j of L_i D_i L_i^T,
</span><span class="comment">*</span><span class="comment">         compute the corresponding eigenvector by forming a
</span><span class="comment">*</span><span class="comment">         rank-revealing twisted factorization.
</span><span class="comment">*</span><span class="comment">  The desired accuracy of the output can be specified by the input
</span><span class="comment">*</span><span class="comment">  parameter ABSTOL.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  For more details, see &quot;A new O(n^2) algorithm for the symmetric
</span><span class="comment">*</span><span class="comment">  tridiagonal eigenvalue/eigenvector problem&quot;, by Inderjit Dhillon,
</span><span class="comment">*</span><span class="comment">  Computer Science Division Technical Report No. UCB//CSD-97-971,
</span><span class="comment">*</span><span class="comment">  UC Berkeley, May 1997.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Note 1 : <a name="SSTEVR.53"></a><a href="sstevr.f.html#SSTEVR.1">SSTEVR</a> calls <a name="SSTEMR.53"></a><a href="sstemr.f.html#SSTEMR.1">SSTEMR</a> when the full spectrum is requested
</span><span class="comment">*</span><span class="comment">  on machines which conform to the ieee-754 floating point standard.
</span><span class="comment">*</span><span class="comment">  <a name="SSTEVR.55"></a><a href="sstevr.f.html#SSTEVR.1">SSTEVR</a> calls <a name="SSTEBZ.55"></a><a href="sstebz.f.html#SSTEBZ.1">SSTEBZ</a> and <a name="SSTEIN.55"></a><a href="sstein.f.html#SSTEIN.1">SSTEIN</a> on non-ieee machines and
</span><span class="comment">*</span><span class="comment">  when partial spectrum requests are made.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Normal execution of <a name="SSTEMR.58"></a><a href="sstemr.f.html#SSTEMR.1">SSTEMR</a> may create NaNs and infinities and
</span><span class="comment">*</span><span class="comment">  hence may abort due to a floating point exception in environments
</span><span class="comment">*</span><span class="comment">  which do not handle NaNs and infinities in the ieee standard default
</span><span class="comment">*</span><span class="comment">  manner.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  JOBZ    (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          = 'N':  Compute eigenvalues only;
</span><span class="comment">*</span><span class="comment">          = 'V':  Compute eigenvalues and eigenvectors.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  RANGE   (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          = 'A': all eigenvalues will be found.
</span><span class="comment">*</span><span class="comment">          = 'V': all eigenvalues in the half-open interval (VL,VU]
</span><span class="comment">*</span><span class="comment">                 will be found.
</span><span class="comment">*</span><span class="comment">          = 'I': the IL-th through IU-th eigenvalues will be found.
</span><span class="comment">*</span><span class="comment">********* For RANGE = 'V' or 'I' and IU - IL &lt; N - 1, <a name="SSTEBZ.75"></a><a href="sstebz.f.html#SSTEBZ.1">SSTEBZ</a> and
</span><span class="comment">*</span><span class="comment">********* <a name="SSTEIN.76"></a><a href="sstein.f.html#SSTEIN.1">SSTEIN</a> are called
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the matrix.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  D       (input/output) REAL array, dimension (N)
</span><span class="comment">*</span><span class="comment">          On entry, the n diagonal elements of the tridiagonal matrix
</span><span class="comment">*</span><span class="comment">          A.
</span><span class="comment">*</span><span class="comment">          On exit, D may be multiplied by a constant factor chosen
</span><span class="comment">*</span><span class="comment">          to avoid over/underflow in computing the eigenvalues.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  E       (input/output) REAL array, dimension (max(1,N-1))
</span><span class="comment">*</span><span class="comment">          On entry, the (n-1) subdiagonal elements of the tridiagonal
</span><span class="comment">*</span><span class="comment">          matrix A in elements 1 to N-1 of E.
</span><span class="comment">*</span><span class="comment">          On exit, E may be multiplied by a constant factor chosen
</span><span class="comment">*</span><span class="comment">          to avoid over/underflow in computing the eigenvalues.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  VL      (input) REAL
</span><span class="comment">*</span><span class="comment">  VU      (input) REAL
</span><span class="comment">*</span><span class="comment">          If RANGE='V', the lower and upper bounds of the interval to
</span><span class="comment">*</span><span class="comment">          be searched for eigenvalues. VL &lt; VU.
</span><span class="comment">*</span><span class="comment">          Not referenced if RANGE = 'A' or 'I'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  IL      (input) INTEGER
</span><span class="comment">*</span><span class="comment">  IU      (input) INTEGER
</span><span class="comment">*</span><span class="comment">          If RANGE='I', the indices (in ascending order) of the
</span><span class="comment">*</span><span class="comment">          smallest and largest eigenvalues to be returned.
</span><span class="comment">*</span><span class="comment">          1 &lt;= IL &lt;= IU &lt;= N, if N &gt; 0; IL = 1 and IU = 0 if N = 0.
</span><span class="comment">*</span><span class="comment">          Not referenced if RANGE = 'A' or 'V'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  ABSTOL  (input) REAL
</span><span class="comment">*</span><span class="comment">          The absolute error tolerance for the eigenvalues.
</span><span class="comment">*</span><span class="comment">          An approximate eigenvalue is accepted as converged
</span><span class="comment">*</span><span class="comment">          when it is determined to lie in an interval [a,b]
</span><span class="comment">*</span><span class="comment">          of width less than or equal to
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                  ABSTOL + EPS *   max( |a|,|b| ) ,
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          where EPS is the machine precision.  If ABSTOL is less than
</span><span class="comment">*</span><span class="comment">          or equal to zero, then  EPS*|T|  will be used in its place,
</span><span class="comment">*</span><span class="comment">          where |T| is the 1-norm of the tridiagonal matrix obtained
</span><span class="comment">*</span><span class="comment">          by reducing A to tridiagonal form.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          See &quot;Computing Small Singular Values of Bidiagonal Matrices
</span><span class="comment">*</span><span class="comment">          with Guaranteed High Relative Accuracy,&quot; by Demmel and
</span><span class="comment">*</span><span class="comment">          Kahan, LAPACK Working Note #3.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          If high relative accuracy is important, set ABSTOL to
</span><span class="comment">*</span><span class="comment">          <a name="SLAMCH.124"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( 'Safe minimum' ).  Doing so will guarantee that
</span><span class="comment">*</span><span class="comment">          eigenvalues are computed to high relative accuracy when
</span><span class="comment">*</span><span class="comment">          possible in future releases.  The current code does not
</span><span class="comment">*</span><span class="comment">          make any guarantees about high relative accuracy, but
</span><span class="comment">*</span><span class="comment">          future releases will. See J. Barlow and J. Demmel,
</span><span class="comment">*</span><span class="comment">          &quot;Computing Accurate Eigensystems of Scaled Diagonally
</span><span class="comment">*</span><span class="comment">          Dominant Matrices&quot;, LAPACK Working Note #7, for a discussion
</span><span class="comment">*</span><span class="comment">          of which matrices define their eigenvalues to high relative
</span><span class="comment">*</span><span class="comment">          accuracy.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  M       (output) INTEGER
</span><span class="comment">*</span><span class="comment">          The total number of eigenvalues found.  0 &lt;= M &lt;= N.
</span><span class="comment">*</span><span class="comment">          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  W       (output) REAL array, dimension (N)
</span><span class="comment">*</span><span class="comment">          The first M elements contain the selected eigenvalues in
</span><span class="comment">*</span><span class="comment">          ascending order.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Z       (output) REAL array, dimension (LDZ, max(1,M) )
</span><span class="comment">*</span><span class="comment">          If JOBZ = 'V', then if INFO = 0, the first M columns of Z
</span><span class="comment">*</span><span class="comment">          contain the orthonormal eigenvectors of the matrix A
</span><span class="comment">*</span><span class="comment">          corresponding to the selected eigenvalues, with the i-th
</span><span class="comment">*</span><span class="comment">          column of Z holding the eigenvector associated with W(i).
</span><span class="comment">*</span><span class="comment">          Note: the user must ensure that at least max(1,M) columns are
</span><span class="comment">*</span><span class="comment">          supplied in the array Z; if RANGE = 'V', the exact value of M
</span><span class="comment">*</span><span class="comment">          is not known in advance and an upper bound must be used.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDZ     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array Z.  LDZ &gt;= 1, and if
</span><span class="comment">*</span><span class="comment">          JOBZ = 'V', LDZ &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  ISUPPZ  (output) INTEGER array, dimension ( 2*max(1,M) )
</span><span class="comment">*</span><span class="comment">          The support of the eigenvectors in Z, i.e., the indices
</span><span class="comment">*</span><span class="comment">          indicating the nonzero elements in Z. The i-th eigenvector
</span><span class="comment">*</span><span class="comment">          is nonzero only in elements ISUPPZ( 2*i-1 ) through
</span><span class="comment">*</span><span class="comment">          ISUPPZ( 2*i ).
</span><span class="comment">*</span><span class="comment">********* Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK    (workspace/output) REAL array, dimension (MAX(1,LWORK))
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, WORK(1) returns the optimal (and
</span><span class="comment">*</span><span class="comment">          minimal) LWORK.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LWORK   (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The dimension of the array WORK.  LWORK &gt;= 20*N.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          If LWORK = -1, then a workspace query is assumed; the routine
</span><span class="comment">*</span><span class="comment">          only calculates the optimal sizes of the WORK and IWORK
</span><span class="comment">*</span><span class="comment">          arrays, returns these values as the first entries of the WORK
</span><span class="comment">*</span><span class="comment">          and IWORK arrays, and no error message related to LWORK or
</span><span class="comment">*</span><span class="comment">          LIWORK is issued by <a name="XERBLA.173"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  IWORK   (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, IWORK(1) returns the optimal (and
</span><span class="comment">*</span><span class="comment">          minimal) LIWORK.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LIWORK  (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The dimension of the array IWORK.  LIWORK &gt;= 10*N.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          If LIWORK = -1, then a workspace query is assumed; the
</span><span class="comment">*</span><span class="comment">          routine only calculates the optimal sizes of the WORK and
</span><span class="comment">*</span><span class="comment">          IWORK arrays, returns these values as the first entries of
</span><span class="comment">*</span><span class="comment">          the WORK and IWORK arrays, and no error message related to
</span><span class="comment">*</span><span class="comment">          LWORK or LIWORK is issued by <a name="XERBLA.186"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          = 0:  successful exit
</span><span class="comment">*</span><span class="comment">          &lt; 0:  if INFO = -i, the i-th argument had an illegal value
</span><span class="comment">*</span><span class="comment">          &gt; 0:  Internal error
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Further Details
</span><span class="comment">*</span><span class="comment">  ===============
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Based on contributions by
</span><span class="comment">*</span><span class="comment">     Inderjit Dhillon, IBM Almaden, USA
</span><span class="comment">*</span><span class="comment">     Osni Marques, LBNL/NERSC, USA
</span><span class="comment">*</span><span class="comment">     Ken Stanley, Computer Science Division, University of
</span><span class="comment">*</span><span class="comment">       California at Berkeley, USA
</span><span class="comment">*</span><span class="comment">     Jason Riedy, Computer Science Division, University of
</span><span class="comment">*</span><span class="comment">       California at Berkeley, USA
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      REAL               ZERO, ONE, TWO
      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0, TWO = 2.0E+0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      LOGICAL            ALLEIG, INDEIG, TEST, LQUERY, VALEIG, WANTZ,
     $                   TRYRAC
      CHARACTER          ORDER
      INTEGER            I, IEEEOK, IMAX, INDIBL, INDIFL, INDISP,
     $                   INDIWO, ISCALE, J, JJ, LIWMIN, LWMIN, NSPLIT
      REAL               BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, SMLNUM,
     $                   TMP1, TNRM, VLL, VUU
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.220"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      INTEGER            <a name="ILAENV.221"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>
      REAL               <a name="SLAMCH.222"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANST.222"></a><a href="slanst.f.html#SLANST.1">SLANST</a>
      EXTERNAL           <a name="LSAME.223"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="ILAENV.223"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>, <a name="SLAMCH.223"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANST.223"></a><a href="slanst.f.html#SLANST.1">SLANST</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           SCOPY, SSCAL, <a name="SSTEBZ.226"></a><a href="sstebz.f.html#SSTEBZ.1">SSTEBZ</a>, <a name="SSTEMR.226"></a><a href="sstemr.f.html#SSTEMR.1">SSTEMR</a>, <a name="SSTEIN.226"></a><a href="sstein.f.html#SSTEIN.1">SSTEIN</a>, <a name="SSTERF.226"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a>,
     $                   SSWAP, <a name="XERBLA.227"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          MAX, MIN, SQRT
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span>      IEEEOK = <a name="ILAENV.237"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 10, <span class="string">'<a name="SSTEVR.237"></a><a href="sstevr.f.html#SSTEVR.1">SSTEVR</a>'</span>, <span class="string">'N'</span>, 1, 2, 3, 4 )
<span class="comment">*</span><span class="comment">
</span>      WANTZ = <a name="LSAME.239"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBZ, <span class="string">'V'</span> )
      ALLEIG = <a name="LSAME.240"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( RANGE, <span class="string">'A'</span> )
      VALEIG = <a name="LSAME.241"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( RANGE, <span class="string">'V'</span> )
      INDEIG = <a name="LSAME.242"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( RANGE, <span class="string">'I'</span> )
<span class="comment">*</span><span class="comment">
</span>      LQUERY = ( ( LWORK.EQ.-1 ) .OR. ( LIWORK.EQ.-1 ) )
      LWMIN = MAX( 1, 20*N )
      LIWMIN = MAX(1, 10*N )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      IF( .NOT.( WANTZ .OR. <a name="LSAME.250"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBZ, <span class="string">'N'</span> ) ) ) THEN
         INFO = -1
      ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
         INFO = -2
      ELSE IF( N.LT.0 ) THEN
         INFO = -3
      ELSE
         IF( VALEIG ) THEN
            IF( N.GT.0 .AND. VU.LE.VL )
     $         INFO = -7
         ELSE IF( INDEIG ) THEN
            IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
               INFO = -8
            ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
               INFO = -9
            END IF
         END IF
      END IF
      IF( INFO.EQ.0 ) THEN
         IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
            INFO = -14
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( INFO.EQ.0 ) THEN
         WORK( 1 ) = LWMIN
         IWORK( 1 ) = LIWMIN
<span class="comment">*</span><span class="comment">
</span>         IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
            INFO = -17
         ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
            INFO = -19
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.286"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SSTEVR.286"></a><a href="sstevr.f.html#SSTEVR.1">SSTEVR</a>'</span>, -INFO )
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      M = 0
      IF( N.EQ.0 )
     $   RETURN
<span class="comment">*</span><span class="comment">
</span>      IF( N.EQ.1 ) THEN
         IF( ALLEIG .OR. INDEIG ) THEN
            M = 1
            W( 1 ) = D( 1 )
         ELSE
            IF( VL.LT.D( 1 ) .AND. VU.GE.D( 1 ) ) THEN
               M = 1
               W( 1 ) = D( 1 )
            END IF
         END IF
         IF( WANTZ )
     $      Z( 1, 1 ) = ONE
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Get machine constants.
</span><span class="comment">*</span><span class="comment">
</span>      SAFMIN = <a name="SLAMCH.315"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'Safe minimum'</span> )
      EPS = <a name="SLAMCH.316"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'Precision'</span> )
      SMLNUM = SAFMIN / EPS
      BIGNUM = ONE / SMLNUM
      RMIN = SQRT( SMLNUM )
      RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Scale matrix to allowable range, if necessary.
</span><span class="comment">*</span><span class="comment">
</span>      ISCALE = 0
      VLL = VL
      VUU = VU
<span class="comment">*</span><span class="comment">
</span>      TNRM = <a name="SLANST.329"></a><a href="slanst.f.html#SLANST.1">SLANST</a>( <span class="string">'M'</span>, N, D, E )
      IF( TNRM.GT.ZERO .AND. TNRM.LT.RMIN ) THEN
         ISCALE = 1
         SIGMA = RMIN / TNRM
      ELSE IF( TNRM.GT.RMAX ) THEN
         ISCALE = 1
         SIGMA = RMAX / TNRM
      END IF
      IF( ISCALE.EQ.1 ) THEN
         CALL SSCAL( N, SIGMA, D, 1 )
         CALL SSCAL( N-1, SIGMA, E( 1 ), 1 )
         IF( VALEIG ) THEN
            VLL = VL*SIGMA
            VUU = VU*SIGMA
         END IF
      END IF

<span class="comment">*</span><span class="comment">     Initialize indices into workspaces.  Note: These indices are used only
</span><span class="comment">*</span><span class="comment">     if <a name="SSTERF.347"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a> or <a name="SSTEMR.347"></a><a href="sstemr.f.html#SSTEMR.1">SSTEMR</a> fail.
</span>
<span class="comment">*</span><span class="comment">     IWORK(INDIBL:INDIBL+M-1) corresponds to IBLOCK in <a name="SSTEBZ.349"></a><a href="sstebz.f.html#SSTEBZ.1">SSTEBZ</a> and
</span><span class="comment">*</span><span class="comment">     stores the block indices of each of the M&lt;=N eigenvalues.
</span>      INDIBL = 1
<span class="comment">*</span><span class="comment">     IWORK(INDISP:INDISP+NSPLIT-1) corresponds to ISPLIT in <a name="SSTEBZ.352"></a><a href="sstebz.f.html#SSTEBZ.1">SSTEBZ</a> and
</span><span class="comment">*</span><span class="comment">     stores the starting and finishing indices of each block.
</span>      INDISP = INDIBL + N
<span class="comment">*</span><span class="comment">     IWORK(INDIFL:INDIFL+N-1) stores the indices of eigenvectors
</span><span class="comment">*</span><span class="comment">     that corresponding to eigenvectors that fail to converge in
</span><span class="comment">*</span><span class="comment">     <a name="SSTEIN.357"></a><a href="sstein.f.html#SSTEIN.1">SSTEIN</a>.  This information is discarded; if any fail, the driver
</span><span class="comment">*</span><span class="comment">     returns INFO &gt; 0.
</span>      INDIFL = INDISP + N
<span class="comment">*</span><span class="comment">     INDIWO is the offset of the remaining integer workspace.
</span>      INDIWO = INDISP + N
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     If all eigenvalues are desired, then
</span><span class="comment">*</span><span class="comment">     call <a name="SSTERF.364"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a> or <a name="SSTEMR.364"></a><a href="sstemr.f.html#SSTEMR.1">SSTEMR</a>.  If this fails for some eigenvalue, then
</span><span class="comment">*</span><span class="comment">     try <a name="SSTEBZ.365"></a><a href="sstebz.f.html#SSTEBZ.1">SSTEBZ</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span>      TEST = .FALSE.
      IF( INDEIG ) THEN
         IF( IL.EQ.1 .AND. IU.EQ.N ) THEN
            TEST = .TRUE.
         END IF
      END IF
      IF( ( ALLEIG .OR. TEST ) .AND. IEEEOK.EQ.1 ) THEN
         CALL SCOPY( N-1, E( 1 ), 1, WORK( 1 ), 1 )
         IF( .NOT.WANTZ ) THEN
            CALL SCOPY( N, D, 1, W, 1 )
            CALL <a name="SSTERF.378"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a>( N, W, WORK, INFO )
         ELSE
            CALL SCOPY( N, D, 1, WORK( N+1 ), 1 )
            IF (ABSTOL .LE. TWO*N*EPS) THEN
               TRYRAC = .TRUE.
            ELSE
               TRYRAC = .FALSE.
            END IF
            CALL <a name="SSTEMR.386"></a><a href="sstemr.f.html#SSTEMR.1">SSTEMR</a>( JOBZ, <span class="string">'A'</span>, N, WORK( N+1 ), WORK, VL, VU, IL,
     $                   IU, M, W, Z, LDZ, N, ISUPPZ, TRYRAC,
     $                   WORK( 2*N+1 ), LWORK-2*N, IWORK, LIWORK, INFO )
<span class="comment">*</span><span class="comment">
</span>         END IF
         IF( INFO.EQ.0 ) THEN
            M = N
            GO TO 10
         END IF
         INFO = 0
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Otherwise, call <a name="SSTEBZ.398"></a><a href="sstebz.f.html#SSTEBZ.1">SSTEBZ</a> and, if eigenvectors are desired, <a name="SSTEIN.398"></a><a href="sstein.f.html#SSTEIN.1">SSTEIN</a>.
</span><span class="comment">*</span><span class="comment">
</span>      IF( WANTZ ) THEN
         ORDER = <span class="string">'B'</span>
      ELSE
         ORDER = <span class="string">'E'</span>
      END IF

      CALL <a name="SSTEBZ.406"></a><a href="sstebz.f.html#SSTEBZ.1">SSTEBZ</a>( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTOL, D, E, M,
     $             NSPLIT, W, IWORK( INDIBL ), IWORK( INDISP ), WORK,
     $             IWORK( INDIWO ), INFO )
<span class="comment">*</span><span class="comment">
</span>      IF( WANTZ ) THEN
         CALL <a name="SSTEIN.411"></a><a href="sstein.f.html#SSTEIN.1">SSTEIN</a>( N, D, E, M, W, IWORK( INDIBL ), IWORK( INDISP ),
     $                Z, LDZ, WORK, IWORK( INDIWO ), IWORK( INDIFL ),
     $                INFO )
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     If matrix was scaled, then rescale eigenvalues appropriately.
</span><span class="comment">*</span><span class="comment">
</span>   10 CONTINUE
      IF( ISCALE.EQ.1 ) THEN
         IF( INFO.EQ.0 ) THEN
            IMAX = M
         ELSE
            IMAX = INFO - 1
         END IF
         CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     If eigenvalues are not in order, then sort them, along with
</span><span class="comment">*</span><span class="comment">     eigenvectors.
</span><span class="comment">*</span><span class="comment">
</span>      IF( WANTZ ) THEN
         DO 30 J = 1, M - 1
            I = 0
            TMP1 = W( J )
            DO 20 JJ = J + 1, M
               IF( W( JJ ).LT.TMP1 ) THEN
                  I = JJ
                  TMP1 = W( JJ )
               END IF
   20       CONTINUE
<span class="comment">*</span><span class="comment">
</span>            IF( I.NE.0 ) THEN
               W( I ) = W( J )
               W( J ) = TMP1
               CALL SSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
            END IF
   30    CONTINUE
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">      Causes problems with tests 19 &amp; 20:
</span><span class="comment">*</span><span class="comment">      IF (wantz .and. INDEIG ) Z( 1,1) = Z(1,1) / 1.002 + .002
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span>      WORK( 1 ) = LWMIN
      IWORK( 1 ) = LIWMIN
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="SSTEVR.458"></a><a href="sstevr.f.html#SSTEVR.1">SSTEVR</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
